# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>

pkgname=python-ujson
_pkgname=ultrajson
pkgver=5.7.0
pkgrel=2
pkgdesc="Ultra fast JSON encoder and decoder for Python"
url="https://github.com/ultrajson/ultrajson"
arch=('loong64' 'x86_64')
license=('BSD')
depends=('python')
makedepends=(python-setuptools-scm python-wheel python-build python-installer)
checkdepends=('python-six' 'python-pytest')
source=(https://github.com/ultrajson/ultrajson/archive/$pkgver/$pkgname-$pkgver.tar.gz)
sha512sums=('12a330d2b005893c010c65d9a2ae8de3e15d3597671123ae2401de4ce835be0fb5e085b50bb575b7053d7c812a6a2115212f30e29ce0a8eb0ddf37cfa668ee77')
b2sums=('4e70fe5aa9cf33d8ad4dfbd0d90928605d19d1e9baf7143c8592a5ffdd4db61310a333aac946500a8dc5702c623ddeb67c40138908b6437e2092f33787e1184c')

export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver

build() {
  cd ${_pkgname}-${pkgver}
  python -m build --wheel --no-isolation
}

check() {
  cd ${_pkgname}-${pkgver}
  local PYTHONVERSION="$(python -c 'import sys; print("{}{}".format(sys.version_info.major, sys.version_info.minor))')"
  PYTHONPATH="build/lib.linux-${CARCH}-cpython-${PYTHONVERSION}" pytest
}

package() {
  cd ${_pkgname}-${pkgver}
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim: ts=2 sw=2 et:
